/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserInterface.java
 *
 * Created on Feb 17, 2011, 1:07:29 PM
 */

package cs342.project1.mathNotebook.gui;

import cs342.project1.mathNotebook.data.*;
import cs342.project1.mathNotebook.notebook.NotebookEntry;
import cs342.project1.mathNotebook.notebook.NotebookEntryListModel;
import cs342.project1.mathNotebook.notebook.SlopeTable;

import java.awt.Desktop;
import java.io.*;
import java.io.IOException;

import java.text.DecimalFormat;

import java.util.zip.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.JTable;
import java.math.*;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;

import java.util.Vector;


/**
 * Advanced User Interface for displaying graphs of formula's finding tangents and manipulating expressions.
 *
 * @author butzem57
 */
public class UserInterface extends javax.swing.JFrame {
    /**
     * Serves as the model for the list of notebook entries displayed to the user.
     */
    private List<NotebookEntry> notebookEntries;
    
    /**
     * View Model for the GUI's list of notebook entries
     */
    private NotebookEntryListModel notebookEntriesListModel;
    private SlopeTable slopeTable;
    private NotebookEntry ne;
    private String input;
    private String currentFilename;


    
    /** Creates new form UserInterface
     */
    public UserInterface() {
        this.notebookEntries = new ArrayList<NotebookEntry>();
        this.connectserver();
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        listPnl = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        notebookEntryJList = new javax.swing.JList();
        newExpBtn = new javax.swing.JButton();
        removeExpBtn = new javax.swing.JButton();
        viewPnl = new javax.swing.JPanel();
        formulaLbl = new javax.swing.JLabel();
        formulaTxt = new javax.swing.JTextField();
        minXLbl = new javax.swing.JLabel();
        lblDimensions = new javax.swing.JLabel();
        maxXLbl = new javax.swing.JLabel();
        minYLbl = new javax.swing.JLabel();
        maxYLbl = new javax.swing.JLabel();
        minXTxt = new javax.swing.JTextField();
        minYTxt = new javax.swing.JTextField();
        maxYTxt = new javax.swing.JTextField();
        maxXTxt = new javax.swing.JTextField();
        areaLbl = new javax.swing.JLabel();
        areaTxt = new javax.swing.JLabel();
        tangentLbl = new javax.swing.JLabel();
        slopeSbr = new javax.swing.JScrollPane();
        slopeTbl = new javax.swing.JTable();
        slopeBtn = new javax.swing.JButton();
        graphMaxY = new javax.swing.JLabel();
        graphMinY = new javax.swing.JLabel();
        graphMinX = new javax.swing.JLabel();
        graphMaxX = new javax.swing.JLabel();
        graph1 = new cs342.project1.mathNotebook.gui.Graph();
        drawBtn = new javax.swing.JButton();
        removeSlopeBtn = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        openCompMenuItem = new javax.swing.JMenuItem();
        saveAsCompMenuItem = new javax.swing.JMenuItem();
        openCompEncMenuItem = new javax.swing.JMenuItem();
        saveAsCompEncMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();
        loginServer = new javax.swing.JMenu();
        Login = new javax.swing.JMenuItem();
        loginOnCloudMenuItem = new javax.swing.JMenuItem();
        openOnCloudMenuItem = new javax.swing.JMenuItem();
        saveAsOnCloudMenuItem = new javax.swing.JMenuItem();
        filesOnCloudMenuItem = new javax.swing.JMenuItem();
        CreateUserOnCloudMenuItem  = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Math Notebook - Alejandro, Mack, Jared");

        notebookEntryJList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                notebookEntryJListMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(notebookEntryJList);

        newExpBtn.setText("New Expression");
        newExpBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newExpBtnActionPerformed(evt);
            }
        });

        removeExpBtn.setText("Remove Expression");
        removeExpBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeExpBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout listPnlLayout = new javax.swing.GroupLayout(listPnl);
        listPnl.setLayout(listPnlLayout);
        listPnlLayout.setHorizontalGroup(
            listPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(listPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(listPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(newExpBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(removeExpBtn))
                .addContainerGap())
        );
        listPnlLayout.setVerticalGroup(
            listPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, listPnlLayout.createSequentialGroup()
                .addContainerGap(42, Short.MAX_VALUE)
                .addComponent(newExpBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(removeExpBtn)
                .addGap(67, 67, 67))
        );

        formulaLbl.setText("Formula:");

        formulaTxt.setEditable(false);

        minXLbl.setText("Min X");

        lblDimensions.setText("Graph Dimensions:");

        maxXLbl.setText("Max X");

        minYLbl.setText("Min Y");

        maxYLbl.setText("Max Y");

        areaLbl.setText("Area:");

        areaTxt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        tangentLbl.setText("Tangents Calculations:");

        slopeTbl.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "X", "Slope"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        slopeSbr.setViewportView(slopeTbl);

        slopeBtn.setFont(new java.awt.Font("Dialog", 1, 10));
        slopeBtn.setText("New Slope");
        slopeBtn.setMaximumSize(new java.awt.Dimension(50, 23));
        slopeBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                slopeBtnActionPerformed(evt);
            }
        });

        graphMaxY.setText("5.0");

        graphMinY.setText("-5.0");

        graphMinX.setText("-5.0");

        graphMaxX.setText("5.0");

        javax.swing.GroupLayout graph1Layout = new javax.swing.GroupLayout(graph1);
        graph1.setLayout(graph1Layout);
        graph1Layout.setHorizontalGroup(
            graph1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 471, Short.MAX_VALUE)
        );
        graph1Layout.setVerticalGroup(
            graph1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 166, Short.MAX_VALUE)
        );

        drawBtn.setText("Draw");
        drawBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawBtnActionPerformed(evt);
            }
        });

        removeSlopeBtn.setFont(new java.awt.Font("Dialog", 1, 10));
        removeSlopeBtn.setText("Remove Slope");
        removeSlopeBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeSlopeBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout viewPnlLayout = new javax.swing.GroupLayout(viewPnl);
        viewPnl.setLayout(viewPnlLayout);
        viewPnlLayout.setHorizontalGroup(
            viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(viewPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(viewPnlLayout.createSequentialGroup()
                        .addComponent(formulaLbl)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(formulaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(viewPnlLayout.createSequentialGroup()
                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(viewPnlLayout.createSequentialGroup()
                                .addComponent(lblDimensions)
                                .addGap(107, 107, 107)
                                .addComponent(tangentLbl))
                            .addGroup(viewPnlLayout.createSequentialGroup()
                                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(viewPnlLayout.createSequentialGroup()
                                        .addGap(12, 12, 12)
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(minXLbl)
                                            .addComponent(minYLbl)))
                                    .addComponent(areaLbl))
                                .addGap(18, 18, 18)
                                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(viewPnlLayout.createSequentialGroup()
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(minXTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(minYTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(viewPnlLayout.createSequentialGroup()
                                                .addComponent(maxXLbl)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(maxXTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(viewPnlLayout.createSequentialGroup()
                                                .addComponent(maxYLbl)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(maxYTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addComponent(drawBtn)
                                    .addComponent(areaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(slopeSbr, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(12, 12, 12)
                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(slopeBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(removeSlopeBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(viewPnlLayout.createSequentialGroup()
                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(graphMaxY)
                            .addComponent(graphMinY, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(viewPnlLayout.createSequentialGroup()
                                .addComponent(graphMinX)
                                .addGap(426, 426, 426)
                                .addComponent(graphMaxX, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(graph1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(63, Short.MAX_VALUE))
        );
        viewPnlLayout.setVerticalGroup(
            viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(viewPnlLayout.createSequentialGroup()
                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(formulaLbl)
                    .addComponent(formulaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(viewPnlLayout.createSequentialGroup()
                        .addComponent(graphMaxY)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(graphMinY))
                    .addComponent(graph1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(viewPnlLayout.createSequentialGroup()
                        .addComponent(graphMinX)
                        .addGap(71, 71, 71)
                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(viewPnlLayout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblDimensions)
                                    .addComponent(tangentLbl))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(viewPnlLayout.createSequentialGroup()
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(minXLbl)
                                            .addComponent(maxXLbl)
                                            .addComponent(minXTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(maxXTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(minYLbl)
                                            .addComponent(maxYLbl)
                                            .addComponent(maxYTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(minYTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(viewPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(areaLbl)
                                            .addComponent(areaTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(15, 15, 15)
                                        .addComponent(drawBtn))
                                    .addComponent(slopeSbr, 0, 0, Short.MAX_VALUE)))
                            .addGroup(viewPnlLayout.createSequentialGroup()
                                .addGap(24, 24, 24)
                                .addComponent(slopeBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(removeSlopeBtn))))
                    .addComponent(graphMaxX, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(45, 45, 45))
        );

        fileMenu.setText("File");

        newMenuItem.setText("New");
        newMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(newMenuItem);

        openMenuItem.setText("Open");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        saveMenuItem.setText("Save");
        saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setText("Save As ...");
        saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveAsMenuItem);

        openCompMenuItem.setText("Open Compressed");
        openCompMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openCompMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openCompMenuItem);

        saveAsCompMenuItem.setText("Compressed Save");
        saveAsCompMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsCompMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveAsCompMenuItem);

        openCompEncMenuItem.setText("Open Compressed Encrypted");
        openCompEncMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openCompEncMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openCompEncMenuItem);

        saveAsCompEncMenuItem.setText("Compressed Encrypted Save");
        saveAsCompEncMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsCompEncMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveAsCompEncMenuItem);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText("Help");

        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        loginServer.setText("Server Login");

        CreateUserOnCloudMenuItem.setText("Create User");
        CreateUserOnCloudMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CreateUserOnCloudMenuItemActionPerformed(evt);
            }
        });
        loginServer.add(CreateUserOnCloudMenuItem);

        Login.setText("Login to Cloud");
        Login.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginOnCloudMenuItemActionPerformed(evt);
            }
        });
        loginServer.add(Login);

        filesOnCloudMenuItem.setText("Files on Cloud");
        filesOnCloudMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filesOnCloudMenuItemActionPerformed(evt);
            }
        });
        loginServer.add(filesOnCloudMenuItem);
        filesOnCloudMenuItem.setEnabled(false);

        openOnCloudMenuItem.setText("Open From Cloud");
        openOnCloudMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openOnCloudMenuItemActionPerformed(evt);
            }
        });
        loginServer.add(openOnCloudMenuItem);
        openOnCloudMenuItem.setEnabled(false);

        saveAsOnCloudMenuItem.setText("Save On Cloud");
        saveAsOnCloudMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsOnCloudMenuItemActionPerformed(evt);
            }
        });
        loginServer.add(saveAsOnCloudMenuItem);
        saveAsOnCloudMenuItem.setEnabled(false);

        menuBar.add(loginServer);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(listPnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(viewPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(viewPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addComponent(listPnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /*
     * Closes form.
     */
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed
    
    /*
     * Calculates slope at a particular x value and fills table with slope
     * 
     * @Author Mack Butzen
     * 
     * @param x value (from InputDialog)
     */
    private void slopeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_slopeBtnActionPerformed

        try {
            Double xCord;
            String slope = JOptionPane.showInputDialog("Please enter an 'x' value");
            xCord = Double.parseDouble(slope);

            //For testing purposes.  Shows result of slope calculation.
//            JOptionPane.showMessageDialog(
//                null, roundTwoDecimals(
//                    NotebookEntry.findSlopeAt(
//                        ne.function, Double.parseDouble(slope))));


            ne.tangentPoints.add(xCord);
            
            slopeTable = new SlopeTable(ne);
            slopeTbl.setModel(slopeTable);
            slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
            slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
            slopeTbl.repaint();
            graph1.drawGraph(ne);
        }
        catch (Exception e) {
            JOptionPane.showMessageDialog(null,"Slope not valid");
        }
    }//GEN-LAST:event_slopeBtnActionPerformed

    /*
     * Takes a new expression, draws the expression on graph and adds expression to expression list.
     * 
     *  @Author Mack Butzen
     *  
     *  @param espression (from InputDialog)
     */
    private void newExpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newExpBtnActionPerformed
    try{    
        ne = new NotebookEntry();
        input = JOptionPane.showInputDialog(null, "Please enter an expression");

        Parser p = new  Parser();
        
        ne.function = p.getExpression(input);
    
        ne.minXCoordinate = -5.0;
        ne.maxXCoordinate = 5.0;
        ne.minYCoordinate = -5.0;
        ne.maxYCoordinate = 5.0;
        ne.functionString = input;

        //set graph hash marks
        graphMinX.setText(ne.minXCoordinate + "");
        graphMaxX.setText(ne.maxXCoordinate + "");
        graphMinY.setText(ne.minYCoordinate + "");
        graphMaxY.setText(ne.maxYCoordinate + "");

        //set graph size text boxes
        minXTxt.setText(ne.minXCoordinate + "");
        maxXTxt.setText(ne.maxXCoordinate + "");
        minYTxt.setText(ne.minYCoordinate + "");
        maxYTxt.setText(ne.maxYCoordinate + "");

        //ne.function = p.getExpression(input);

        notebookEntries.add(ne);
        
        formulaTxt.setText(input);
        graph1.drawGraph(ne);
        
        slopeTable = new SlopeTable(ne);
        slopeTbl.setModel(slopeTable);
        slopeTbl.repaint();

        //Get area
        //areaTxt.setText(ne.calculateArea() + "");
        areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");
        
        notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);
        notebookEntryJList.setModel(notebookEntriesListModel);
        notebookEntryJList.repaint();
        
        notebookEntryJList.setSelectedIndex(notebookEntries.size()-1);
        notebookEntryJList.repaint();
        
    }catch(Exception e){
        JOptionPane.showMessageDialog(null,"Expression not valid");
    }
    }//GEN-LAST:event_newExpBtnActionPerformed

    private double roundTwoDecimals(double d) {
        DecimalFormat twoDForm = new DecimalFormat("#.##");
        if ( new Double(d).toString().equals("NaN"))
                return d;
        return Double.valueOf(twoDForm.format(d));
    }

    /*
     * When an expression is selected in the ExpressionList, load the expression as the current exp.
     * 
     * @Author Mack Butzen
     */
    private void notebookEntryJListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_notebookEntryJListMouseClicked
       if(this.notebookEntries.size() == 0) {
           return;
       }
        
        formulaTxt.setText(((NotebookEntry)(notebookEntryJList.getSelectedValue())).functionString);
        ne = (NotebookEntry)(notebookEntryJList.getSelectedValue());
        
        ne.minXCoordinate = -5.0;
        ne.maxXCoordinate = 5.0;
        ne.minYCoordinate = -5.0;
        ne.maxYCoordinate = 5.0;
        
      //set graph hash marks
        graphMinX.setText(ne.minXCoordinate + "");
        graphMaxX.setText(ne.maxXCoordinate + "");
        graphMinY.setText(ne.minYCoordinate + "");
        graphMaxY.setText(ne.maxYCoordinate + "");

        //set graph size text boxes
        minXTxt.setText(ne.minXCoordinate + "");
        maxXTxt.setText(ne.maxXCoordinate + "");
        minYTxt.setText(ne.minYCoordinate + "");
        maxYTxt.setText(ne.maxYCoordinate + "");
        
        areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");
        
        graph1.drawGraph(ne);
        graph1.repaint();
        
        slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
        slopeTbl.setModel(slopeTable);
        slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
        slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
        slopeTbl.repaint();
        
        
    }//GEN-LAST:event_notebookEntryJListMouseClicked
    
    /*
     * Redraws graph with new display parameters
     * 
     * @Author Mack Butzen
     */
    private void drawBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawBtnActionPerformed
        double minx, miny, maxx, maxy;

        try {

            minx = Double.parseDouble(minXTxt.getText());
            maxx = Double.parseDouble(maxXTxt.getText());
            miny = Double.parseDouble(minYTxt.getText());
            maxy = Double.parseDouble(maxYTxt.getText());

            if (minx > maxx || miny > maxy) {
                throw new Exception();
            }
            ne.minXCoordinate = Double.parseDouble(minXTxt.getText());
            ne.maxXCoordinate = Double.parseDouble(maxXTxt.getText());
            ne.minYCoordinate = Double.parseDouble(minYTxt.getText());
            ne.maxYCoordinate = Double.parseDouble(maxYTxt.getText());

            //set graph hash marks
            graphMinX.setText(ne.minXCoordinate + "");
            graphMaxX.setText(ne.maxXCoordinate + "");
            graphMinY.setText(ne.minYCoordinate + "");
            graphMaxY.setText(ne.maxYCoordinate + "");

        //recalculate area
        areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");

        //redraw graph
        graph1.drawGraph(ne);
        
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null,"Graph bounds not valid");
        }
    }//GEN-LAST:event_drawBtnActionPerformed
    
    /**
     * Calls save as if the current notebook has not already saved. If it has
     * been saved before, simply save it to the current file.
     * @author Jared Schlicht
     * @param evt
     */
    private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed
        if (this.currentFilename != null) {
                this.saveFile();
        } else {
                this.saveFileAs();
        }
    }//GEN-LAST:event_saveMenuItemActionPerformed
    
    /**
     * Creates a new notebook
     * @author Jared Schlicht
     * @param evt
     */
    private void newMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newMenuItemActionPerformed
        this.notebookEntries.clear();
        this.currentFilename = null;
        this.notebookEntryJList.repaint();
        this.areaTxt.setText("");
        this.formulaTxt.setText("");
        
        this.graphMaxX.setText("");
        this.maxXTxt.setText("");
        
        this.graphMaxY.setText("");
        this.maxYTxt.setText("");
        
        this.graphMinX.setText("");
        this.minXTxt.setText("");
        
        this.graphMinY.setText("");
        this.minYTxt.setText("");
        
        this.ne = null;
        this.graph1.drawGraph(this.ne);
        
        slopeTbl.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null},
                    {null, null},
                    {null, null},
                    {null, null}
                },
                new String [] {
                    "X", "Slope"
                }
            ) {
                Class[] types = new Class [] {
                    java.lang.String.class, java.lang.String.class
                };

                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }
            });
        slopeTbl.repaint();

        openfromserver = false;
        // this.slopeTable.slopeT.get(0).clear();
        // this.slopeTable.slopeT.get(1).clear();
        // this.slopeTable.entry = null;
        // this.slopeTable.slopeT = new Double[0][0];
    }//GEN-LAST:event_newMenuItemActionPerformed
    
    /**
     * Opens ExpressionList from XML
     *
     * @Author Mack Butzen
     */
    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        
        int openResult = fileChooser.showOpenDialog(this);
        if (openResult != JFileChooser.APPROVE_OPTION) {
            return;
        }

        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();
        
        NotebookReader reader = new XMLNotebookRepositoryFactory(this.currentFilename).createReader();
        notebookEntries = reader.getAll();
        reader.close();
        notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);
        notebookEntryJList.setModel(notebookEntriesListModel);
        notebookEntryJList.repaint();
        
        if(this.notebookEntries.size() == 0) {
           return;
        }
        
        notebookEntryJList.setSelectedIndex(0);
        
        formulaTxt.setText(((NotebookEntry)(notebookEntryJList.getSelectedValue())).functionString);
         ne = (NotebookEntry)(notebookEntryJList.getSelectedValue());

         ne.minXCoordinate = -5.0;
         ne.maxXCoordinate = 5.0;
         ne.minYCoordinate = -5.0;
         ne.maxYCoordinate = 5.0;
         
       //set graph hash marks
         graphMinX.setText(ne.minXCoordinate + "");
         graphMaxX.setText(ne.maxXCoordinate + "");
         graphMinY.setText(ne.minYCoordinate + "");
         graphMaxY.setText(ne.maxYCoordinate + "");

         //set graph size text boxes
         minXTxt.setText(ne.minXCoordinate + "");
         maxXTxt.setText(ne.maxXCoordinate + "");
         minYTxt.setText(ne.minYCoordinate + "");
         maxYTxt.setText(ne.maxYCoordinate + "");
         
         areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");
         
         graph1.drawGraph(ne);
         graph1.repaint();
         
         slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
         slopeTbl.setModel(slopeTable);
         slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
         slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
         slopeTbl.repaint();

	 openfromserver = false;
    }//GEN-LAST:event_openMenuItemActionPerformed

    /**
     * Save current expression list to XML
     * @author Mack Butzen
     */
    private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        this.saveFileAs();
    }                                              


    private void openCompMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        this.openCompressed();
    }                                              


    private void saveAsCompMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        this.saveFileAsCompressed();
    }


    private void openCompEncMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        this.openFileEncrypted();
    }                                              


    private void saveAsCompEncMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        this.saveFileAsEncrypted();
    }

    private void CreateUserOnCloudMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        final JFrame createNewUser = new JFrame("Create A New User");
        JPanel popuppanel;
        FlowLayout fpanel = new FlowLayout();
        popuppanel = new JPanel(fpanel);
        JLabel user = new JLabel();
        user.setText("User Name");
        final JTextField usertext = new JTextField();
        usertext.setColumns(15);

        JLabel password = new JLabel();
        password.setText("Enter Password");
        final JTextField passwordtext = new JTextField();
        passwordtext.setColumns(15);

        JLabel repassword = new JLabel();
        repassword.setText("Re Enter Password");
        final JTextField repasswordtext = new JTextField();
        repasswordtext.setColumns(15);

        JButton sqlconnectb = new JButton();
        sqlconnectb.setText("ENTER");
        sqlconnectb.addActionListener(
            new ActionListener () {
                  public void actionPerformed(ActionEvent e) {
                    String user = usertext.getText();
                    String pass = passwordtext.getText();
                    String repass = repasswordtext.getText();

                    if (pass.equals(repass) && user != null ){
                           instertNewUser(user, pass, createNewUser);
                    }
                     else {
                        JOptionPane.showMessageDialog(null, "PASSWORDS DO NOT MATCH");
                     }

                 }
        });
        popuppanel.add(user);
        popuppanel.add(usertext);
        popuppanel.add(password);
        popuppanel.add(repassword);
        popuppanel.add(passwordtext);
        popuppanel.add(repasswordtext);
        //popuppanel.add(readwriteoption);
        //popuppanel.add(read);
        popuppanel.add(sqlconnectb);
        popuppanel.show(true);
        createNewUser.add(popuppanel);
        createNewUser.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        //userloginpopup.setSize(250, 200);
        createNewUser.setResizable(false);
        createNewUser.setBounds(200, 200, 250, 200);
        createNewUser.setVisible(true);
    }

    public void instertNewUser(String user, String password, JFrame pop){
        try {
            username = user;
            passw = password;

            this.desK();
            this.rsaPubK();
            Statement stmt;

            ByteArrayInputStream pbin = new ByteArrayInputStream(rsa_pub_key.getEncoded());
            System.out.println(rsa_pub_key.getEncoded());
            // Get a Statement object
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM Users WHERE P_Id = "+'"' + user + '"');

            if(rs.next()){
                JOptionPane.showMessageDialog(null,"Already Exists");
            }
            else{
                // Execute a query
                System.out.println(rsa_pub_key.getEncoded().length);
                PreparedStatement ps = null;
                String insertnewuser = "INSERT INTO Users(P_Id, P_Pass, public_Key) VALUES(?,?,?)";
                ps = conn.prepareStatement(insertnewuser);
                ps.setString(1,username);
                ps.setString(2,password);
                ps.setBytes(3,rsa_pub_key.getEncoded());
                ps.executeUpdate();
                pop.dispose();

                conn.commit();
            }
         }catch(SQLException ex) {
            System.err.println("InsertData: " + ex.getMessage());
        }
     }

    private void loginOnCloudMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        //Create new popmenu
        final JFrame userloginpopup = new JFrame("Login On Cloud");
        JPanel popuppanel;
        FlowLayout pppanel = new FlowLayout();
        popuppanel = new JPanel(pppanel);
        JLabel user = new JLabel();
        user.setText("User Name:");
        final JTextField usertext = new JTextField();
        usertext.setColumns(15);
        JLabel password = new JLabel();
        password.setText("Password:");
        final JTextField passwordtext = new JTextField();
        passwordtext.setColumns(15);
        JLabel readwriteoption = new JLabel();
        readwriteoption.setText("Read or Write file:");
        final JCheckBox read = new JCheckBox();
        read.addActionListener(
            new ActionListener () {
                public void actionPerformed(ActionEvent e) {
                    //readwritetosql
                    if(read.isSelected()){readwritetosql = true;
                                         }else{readwritetosql = false;}
                    //System.out.println(readwritetosql);
                }
            });

        JButton sqlconnectb = new JButton();
        sqlconnectb.setText("Connect to Cloud");
        sqlconnectb.addActionListener(
            new ActionListener () {
                public void actionPerformed(ActionEvent e) {
                    String usr = usertext.getText();
                    String prwd = passwordtext.getText();

                    connecttoserver(usr,prwd,userloginpopup);
                }
            });

        popuppanel.add(user);
        popuppanel.add(usertext);
        popuppanel.add(password);
        popuppanel.add(passwordtext);
        //popuppanel.add(readwriteoption);
        //popuppanel.add(read);
        popuppanel.add(sqlconnectb);
        popuppanel.show(true);
        userloginpopup.add(popuppanel);
        userloginpopup.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        //userloginpopup.setSize(250, 200);
        userloginpopup.setResizable(false);
        userloginpopup.setBounds(200, 200, 250, 200);
        userloginpopup.setVisible(true);

        //need to add listener 
    }

    private void filesOnCloudMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
        final JFrame userloginpopup = new JFrame("Login On Cloud");
        JPanel fpopuppanel;
        FlowLayout fpppanel = new FlowLayout();
        fpopuppanel = new JPanel();

        ResultSet rs = null;
        PreparedStatement pstmt = null;
        //Now just have to insert the right query

        String query = "SELECT MyZipBlobs.id,MyZipBlobs.LastUser,MyZipBlobs.name,Files_in_use.Inuse FROM Files_in_use RIGHT JOIN MyZipBlobs ON MyZipBlobs.id=Files_in_use.F_Id";

        Vector data = null;
        Vector col = null;

         try{
         pstmt = conn.prepareStatement(query);
         rs = pstmt.executeQuery();

         ResultSetMetaData md = rs.getMetaData();
         int columnCount = md.getColumnCount();

         col = new Vector(columnCount);

         //storing column names
        for(int i=1; i<=columnCount; i++)
        col.add(md.getColumnName(i));

        data = new Vector();
        Vector row;

        //storing rows
        while(rs.next())
        {
            row = new Vector(columnCount);
            for(int i=1; i<=columnCount; i++)
            {
                row.add(rs.getString(i));
            }
                data.add(row);
        }

        } catch (Exception e) {System.out.println("Error " + e);
            }finally {
            try{
                rs.close();
                pstmt.close();
            }catch (Exception e) {System.out.println("Error " + e);}
        }


        table = new JTable(data, col);
        table.setPreferredScrollableViewportSize(new Dimension(800,145));
        table.addMouseListener(new MouseAdapter() {
                                    public void mouseClicked(MouseEvent e) {
                                        if(table.getModel().getValueAt(table.getSelectedRow(), 3) == null || Integer.parseInt((String) table.getModel().getValueAt(table.getSelectedRow(), 3)) == 0)
                                        {
                                            openfid = Integer.parseInt((String) table.getModel().getValueAt(table.getSelectedRow(), 0));
                                            lastUser = (String) table.getModel().getValueAt(table.getSelectedRow(), 1);
                                            System.out.println(lastUser);
                                            userloginpopup.dispose();
                                        }else{
                                            JOptionPane.showMessageDialog(null, "File is currently in use. Please choose another file.");
                                        }
                                    }
                                }); 
        JTableHeader header = table.getTableHeader();
        header.setBackground(Color.green);
        JScrollPane pane = new JScrollPane(table);
        //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        fpopuppanel.setSize(1000,150);
        fpopuppanel.add(pane);
        fpopuppanel.show(true);
        userloginpopup.add(fpopuppanel,BorderLayout.CENTER);
        userloginpopup.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

        userloginpopup.setResizable(false);
        userloginpopup.setSize(1000,150);
        userloginpopup.setVisible(true);
    }

    private void openOnCloudMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // Retrieve the blob
        ResultSet rs = null;
        PreparedStatement pstmt = null;

        try {
            conn.setAutoCommit(false);
            String id = openfid+"";

            //Besides just the file we will need the public_Key.
            String query = "SELECT b.zip,b.encdes,(Select a.public_Key FROM Users a WHERE a.P_Id=? ) AS ppubkey FROM MyZipBlobs b WHERE (b.id = ?)";
            Blob zfile = null;
            Blob bigdef = null;
            byte[] pubrasf = null;

            System.out.println(lastUser);

            //conn = getConnection();
            pstmt = conn.prepareStatement(query);
            pstmt.setString(1, lastUser);
            pstmt.setString(2, id);

            System.out.println("b 4 execute");
            rs = pstmt.executeQuery();
            rs.last();
            // materialize binary data onto client
            zfile = rs.getBlob(1);
            bigdef = rs.getBlob(2);
            pubrasf = rs.getBytes(3);

            if(zfile == null)
                System.out.println("zfile null");

            if(bigdef == null)
                System.out.println("bigdef file null");

            if(pubrasf == null)
                System.out.println("pubrasf null");

            System.out.println("blobs set.");
            //System.out.println(pubrasf.length());
             //byte[] kb = pubrasf.getBytes(1,(int) pubrasf.length());

            KeyFactory keyFactory = KeyFactory.getInstance("RSA");

            Key ranRSAK = null;
            X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(pubrasf);
            ranRSAK= keyFactory.generatePublic(pubKeySpec);
            System.out.println("key made");
            BigInteger bi = new BigInteger(bigdef.getBytes(1,(int) bigdef.length()));
            System.out.println("big int created.");
            InputStream bin = new ByteArrayInputStream(bi.toByteArray());
            
            Cipher rsa = Cipher.getInstance("rsa");

            //decrypt secretKey using server’s private key
            rsa.init(Cipher.DECRYPT_MODE, ranRSAK);
            //rsa.update(encryptedKey);
            //byte [] decryptedKey = rsa.doFinal();

            String decrypted_string = new String("");
            byte[] input = new byte[64];

            while(true){
                int bytesRead = bin.read(input);
                if(bytesRead == -1) break;

                byte[] output2 = rsa.update(input, 0, bytesRead);
                if(output2 != null) decrypted_string = decrypted_string.concat(new String(output2));
            }

            byte[] output = rsa.doFinal();
            if(output != null) decrypted_string = decrypted_string.concat(new String(output));
            System.out.print("deskey: ");
            System.out.println(decrypted_string);

            /*Place the blob into output.
            this should be a buffer to unzip into and the output is the encrypeted version
            that needs to be decrypted and saved and loaded.*/
            //might create error here filename is not trimmed i think.
            JFileChooser fileChooser = new JFileChooser();
            int result = fileChooser.showSaveDialog(this);
            if (result != JFileChooser.APPROVE_OPTION) {
                return;
            }

            File file = fileChooser.getSelectedFile();
            this.currentFilename = file.getAbsolutePath();
            System.out.println(currentFilename);

            currentFilename += ".des";

            FileOutputStream out; 
            BufferedInputStream in;
            // classic copy loop from in to out with a byte buffer
            int b;
            byte[] buffer = new byte[10240]; // 10kb buffer
           
            out = new FileOutputStream(currentFilename);
            in = new BufferedInputStream(zfile.getBinaryStream());

            while ((b = in.read(buffer, 0, 10240)) != -1) {
                out.write(buffer, 0, b);
            }

            System.out.println("des file created.");

            EncryptionDecryptionHandler.Decryption(currentFilename,desK(decrypted_string));
            String currentFilename1 = currentFilename.substring(0, currentFilename.length() - 4)+".gz";

            CompressionDecompressionHandler.Decompress(currentFilename1);
            String temp = currentFilename1.substring(0, currentFilename1.length() - 3)+".xml";

            NotebookReader reader = new XMLNotebookRepositoryFactory(temp).createReader();
            notebookEntries = reader.getAll();
            reader.close();
            File dFile = new File(temp);
            dFile.delete();

            notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);
            notebookEntryJList.setModel(notebookEntriesListModel);
            notebookEntryJList.repaint();

            if(this.notebookEntries.size() == 0) {
            return;
            }

            notebookEntryJList.setSelectedIndex(0);

            formulaTxt.setText(((NotebookEntry)(notebookEntryJList.getSelectedValue())).functionString);
            ne = (NotebookEntry)(notebookEntryJList.getSelectedValue());

            ne.minXCoordinate = -5.0;
            ne.maxXCoordinate = 5.0;
            ne.minYCoordinate = -5.0;
            ne.maxYCoordinate = 5.0;

            //set graph hash marks
            graphMinX.setText(ne.minXCoordinate + "");
            graphMaxX.setText(ne.maxXCoordinate + "");
            graphMinY.setText(ne.minYCoordinate + "");
            graphMaxY.setText(ne.maxYCoordinate + "");

            //set graph size text boxes
            minXTxt.setText(ne.minXCoordinate + "");
            maxXTxt.setText(ne.maxXCoordinate + "");
            minYTxt.setText(ne.minYCoordinate + "");
            maxYTxt.setText(ne.maxYCoordinate + "");

            areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");

            graph1.drawGraph(ne);
            graph1.repaint();

            slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
            slopeTbl.setModel(slopeTable);
            slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
            slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
            slopeTbl.repaint();

            conn.commit();
            out.close();
        }
        catch (Exception e) { e.printStackTrace();
        }finally {
            try{
                rs.close();
                pstmt.close();
            }catch (Exception e) {System.out.println("Error " + e);}
        }

	//change boolean value to save file later.
	openfromserver = true;
    }

    private void saveAsOnCloudMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuItemActionPerformed
      if(openfromserver)
      {
//           FileInputStream fis = null;
//           PreparedStatement ps = null;
// 
//           try {
//             String ranstr = JOptionPane.showInputDialog ( "Enter secure key that is a length of 8 characters." );
// 
//             SecretKey ranDesKey = desK(ranstr);
// 
//             Cipher rsa;
//             rsa = Cipher.getInstance("RSA");
// 
//             // encrypt decrypted key using client's public key
//             rsa.init(Cipher.ENCRYPT_MODE, rsa_pri_key);
//             rsa.update(ranstr.getBytes());
//             byte [] encryptedKey = rsa.doFinal();
// 
//             ArrayList enc_bytes = new ArrayList();
// 
//             for(int i=0; i<encryptedKey.length; i++)
//                 enc_bytes.add(new Byte(encryptedKey[i]));
// 
//             Object enc_data_warp [] = enc_bytes.toArray();
//             byte enc_data [] = new byte[enc_data_warp.length];
// 
//             for(int i=0; i<enc_data_warp.length; i++)
//                 enc_data[i] = ((Byte) enc_data_warp[i]).byteValue();
// 
//             bi = new BigInteger(enc_data);
// 
//             InputStream bin = new ByteArrayInputStream(bi.toByteArray());
// 
//              if (currentFilename == null) {
//                 JFileChooser fileChooser = new JFileChooser();
//                 int result = fileChooser.showSaveDialog(this);
//                 if (result != JFileChooser.APPROVE_OPTION) {
//                     return;
//                 }
// 
//                 File file = fileChooser.getSelectedFile();
//                 this.currentFilename = file.getAbsolutePath();
//                 System.out.println(currentFilename);
// 
//                 currentFilename += ".xml";
//                 this.saveFile();
//             }
// 
//             CompressionDecompressionHandler.Compress(currentFilename);
//             String currentFilename1 = currentFilename.substring(0,currentFilename.length()-4)+ ".gz";
//             EncryptionDecryptionHandler.Encryption(currentFilename1,ranDesKey);
//             String file_name = currentFilename1.substring(0,currentFilename1.length()-3)+ ".des";
// 
//             String InsertZip = "update MyZipBlobs SET zip=?,LastUser=?,encdes=? WHERE id=?";
// 
//             //this file needs to be compressed and encrypted first.
//             //call the compress function
//             //then call the encrypt function.
//             // THE FILE needs to be saved before we can save it on the
//             File file = new File(file_name);
//             fis = new FileInputStream(file);
//             ps = conn.prepareStatement(InsertZip);
//             ps.setBinaryStream(1, fis, (int) file.length());
//             ps.setString(2,username);
//             ps.setBinaryStream(3,bin,(int) bi.bitLength());
//             ps.setString(4,Integer.toString(openfid));
//             ps.executeUpdate();
// 
//             conn.commit();
// 	  }
// 	  catch (Exception e) {System.out.println("Error " + e);}
// 	  finally {
// 	      try{
// 		  ps.close();
// 		  fis.close();
// 	      }catch (Exception e) {System.out.println("Error " + e);}
// 	  }

          System.out.println("I am coming here");
      }else{

          FileInputStream fis = null;
          PreparedStatement ps = null;

          try {
            //Issues will rise because of id
            // made id in server auto increment.
            //i dont believe we need this at all.
            //will talk to naps about this.
            if (currentFilename == null) {
                JFileChooser fileChooser = new JFileChooser();
                int result = fileChooser.showSaveDialog(this);
                if (result != JFileChooser.APPROVE_OPTION) {
                    return;
                }

                File file = fileChooser.getSelectedFile();
                this.currentFilename = file.getAbsolutePath();
                System.out.println(currentFilename);

                currentFilename += ".xml";
                this.saveFile();
            }

            String ranstr = JOptionPane.showInputDialog ( "Enter secure key that is a length of 8 characters." );

            SecretKey ranDesKey = desK(ranstr);

            Cipher rsa;
            rsa = Cipher.getInstance("RSA");

            // encrypt decrypted key using client's public key
            rsa.init(Cipher.ENCRYPT_MODE, rsa_pri_key);
            rsa.update(ranstr.getBytes());
            byte [] encryptedKey = rsa.doFinal();

            ArrayList enc_bytes = new ArrayList();

            for(int i=0; i<encryptedKey.length; i++)
                enc_bytes.add(new Byte(encryptedKey[i]));

            Object enc_data_warp [] = enc_bytes.toArray();
            byte enc_data [] = new byte[enc_data_warp.length];

            for(int i=0; i<enc_data_warp.length; i++)
                enc_data[i] = ((Byte) enc_data_warp[i]).byteValue();

            bi = new BigInteger(enc_data);

            InputStream bin = new ByteArrayInputStream(bi.toByteArray());

            CompressionDecompressionHandler.Compress(currentFilename);
            File filetempComp = new File(currentFilename);
            filetempComp.delete();
            currentFilename = currentFilename.substring(0, currentFilename.length() - 4)+".gz";//remove xml add gz
            EncryptionDecryptionHandler.Encryption(currentFilename,ranDesKey);
            currentFilename = currentFilename.substring(0, currentFilename.length() - 3)+".des";//remove gz add des
            //changing the path to just the name of the file
            File curFile = new File(currentFilename);
            String fileName= curFile.getName();


            //update. data
            //UPDATE table_name
            //SET column1=value, column2=value2,...
            //WHERE some_column=some_value
            String InsertZip = "INSERT INTO MyZipBlobs(P_Id,name,LastUser,encdes,zip) VALUES(?,?,?,?,?)";

            conn.setAutoCommit(false);
            //this file needs to be compressed and encrypted first.
            //call the compress function
            //then call the encrypt function.
            // THE FILE needs to be saved before we can save it on the
            File file = new File(currentFilename);
            fis = new FileInputStream(file);
            ps = conn.prepareStatement(InsertZip);
            ps.setString(1,username);
            ps.setString(2,fileName);
            ps.setString(3,username);
            ps.setBinaryStream(4,bin,(int) bi.bitLength());
            ps.setBinaryStream(5, fis, (int) file.length());
            ps.executeUpdate();


            bin.close();
            conn.commit();
	  }
	  catch (Exception e) {System.out.println("Error " + e);}
	  finally {
	      try{
		  ps.close();
		  fis.close();
	      }catch (Exception e) {System.out.println("Error " + e);}
	  }
      }
    }//GEN-LAST:event_saveAsMenuItemActionPerformed

    private void connectserver()
    {
        try {
            Class.forName("com.mysql.jdbc.Driver");  // register the driver
            dbURL = "jdbc:mysql://cs346.cs.uwosh.edu:4381/cs342group7";
            System.out.println("Attempting connection");
            conn = DriverManager.getConnection(dbURL,"cs342group7","p5012602");
            System.out.println("Connection successful");
        }
        catch (Exception e) {
            System.out.println("Error " + e);
        }
    }

    private void connecttoserver(String user,String pw,JFrame popup) {
        //System.out.println(user+" "+pw);
        username = user;
        passw = pw;

        // connect to server and check user access.
        ResultSet rs = null;
        PreparedStatement pstmt = null;
        String query = "SELECT P_Id,P_Pass FROM Users WHERE (P_Id = ?) AND (P_Pass = ?)";

        // Establish connection
        try {
            //check query with input.
            pstmt = conn.prepareStatement(query);
            pstmt.setString(1, user);
            pstmt.setString(2, pw);
            rs = pstmt.executeQuery();
            rs.last();

            String tempu = new String (rs.getBytes(1));
            String tempp = new String (rs.getBytes(2));
            System.out.println(rs.getRow()+" "+tempu+" "+tempp);
            if(tempu.equals(user) && tempp.equals(pw))
            {
                //connection succeful dispose of login and enable menu items.
                popup.dispose();
                filesOnCloudMenuItem.setEnabled(true);
                openOnCloudMenuItem.setEnabled(true);
                saveAsOnCloudMenuItem.setEnabled(true);
            }

            this.desK();

            this.rsaPubK();
            //System.out.println();
        }
        catch (Exception e) {
            System.out.println("Error 1 " + e);
        }finally{
            try{
                rs.close();
                pstmt.close();
            }catch (Exception e) {System.out.println("Error 2 " + e);}
        }
    }

    private void desK() {
            try{
                byte[] desKeyData = username.getBytes();
                desKeySpec = new DESKeySpec(desKeyData);
                SecretKeyFactory deskeyFactory = SecretKeyFactory.getInstance("DES");
                desKey = deskeyFactory.generateSecret(desKeySpec);
            }catch (Exception e) {
                e.printStackTrace();
            }
    }

    private SecretKey desK(String desrandom) {
        try{
            byte[] desKeyData = desrandom.getBytes();
            desKeySpec = new DESKeySpec(desKeyData);
            SecretKeyFactory deskeyFactory = SecretKeyFactory.getInstance("DES");
            desKey = deskeyFactory.generateSecret(desKeySpec);
        }catch (Exception e) {
            e.printStackTrace();
        }

        return desKey;
    }

   private void rsaPubK() {
        try{
            KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
            SecureRandom secureSeed = SecureRandom.getInstance("SHA1PRNG");

            //username.trim();
            byte[] keyData = username.getBytes();
            secureSeed.setSeed(keyData);
            kg.initialize(512,secureSeed);
            KeyPair Kpair = kg.generateKeyPair();

            rsa_pub_key = Kpair.getPublic();
            rsa_pri_key = Kpair.getPrivate();
        }catch (Exception e) {e.printStackTrace();}
   }


    private void saveFileAsCompressed(){
        JFileChooser fileChooser = new JFileChooser();
        int result = fileChooser.showSaveDialog(this);
        if (result != JFileChooser.APPROVE_OPTION) {
            return;
        }

        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();
        System.out.println(currentFilename);

        currentFilename += ".xml";
        this.saveFile();
        CompressionDecompressionHandler.Compress(currentFilename);
        File filetempComp = new File(currentFilename);
        filetempComp.delete();


    }

    private void saveFileAsEncrypted(){
        JFileChooser fileChooser = new JFileChooser();
        int result = fileChooser.showSaveDialog(this);
        if (result != JFileChooser.APPROVE_OPTION) {
            return;
        }

        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();

        currentFilename += ".xml";
        this.saveFile();

        CompressionDecompressionHandler.Compress(currentFilename);
        File filetempComp = new File(currentFilename);  
        filetempComp.delete();
        String currentFilename1 = currentFilename.substring(0,currentFilename.length()-4)+ ".gz";
        EncryptionDecryptionHandler.Encryption(currentFilename1,desKey);

    }


    private void openFileEncrypted(){
        JFileChooser fileChooser = new JFileChooser();

        int openResult = fileChooser.showOpenDialog(this);
        if (openResult != JFileChooser.APPROVE_OPTION) {
            return;
        }
        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();

        EncryptionDecryptionHandler.Decryption(currentFilename,desKey);
        String currentFilename1 = currentFilename.substring(0, currentFilename.length() - 4)+".gz";

        CompressionDecompressionHandler.Decompress(currentFilename1);
        String temp = currentFilename1.substring(0, currentFilename1.length() - 3)+".xml";

        NotebookReader reader = new XMLNotebookRepositoryFactory(temp).createReader();
        notebookEntries = reader.getAll();
        reader.close();
        File dFile = new File(temp);
        dFile.delete();

        notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);
        notebookEntryJList.setModel(notebookEntriesListModel);
        notebookEntryJList.repaint();

        if(this.notebookEntries.size() == 0) {
           return;
        }

        notebookEntryJList.setSelectedIndex(0);

        formulaTxt.setText(((NotebookEntry)(notebookEntryJList.getSelectedValue())).functionString);
         ne = (NotebookEntry)(notebookEntryJList.getSelectedValue());

         ne.minXCoordinate = -5.0;
         ne.maxXCoordinate = 5.0;
         ne.minYCoordinate = -5.0;
         ne.maxYCoordinate = 5.0;

       //set graph hash marks
         graphMinX.setText(ne.minXCoordinate + "");
         graphMaxX.setText(ne.maxXCoordinate + "");
         graphMinY.setText(ne.minYCoordinate + "");
         graphMaxY.setText(ne.maxYCoordinate + "");

         //set graph size text boxes
         minXTxt.setText(ne.minXCoordinate + "");
         maxXTxt.setText(ne.maxXCoordinate + "");
         minYTxt.setText(ne.minYCoordinate + "");
         maxYTxt.setText(ne.maxYCoordinate + "");

         areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");

         graph1.drawGraph(ne);
         graph1.repaint();

         slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
         slopeTbl.setModel(slopeTable);
         slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
         slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
         slopeTbl.repaint();

	 openfromserver = false;
    }


    private void openCompressed(){
        JFileChooser fileChooser = new JFileChooser();

        int openResult = fileChooser.showOpenDialog(this);
        if (openResult != JFileChooser.APPROVE_OPTION) {
            return;
        }

        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();

        CompressionDecompressionHandler.Decompress(currentFilename);
        String currentFilename1 = currentFilename.substring(0,currentFilename.length() - 3) + ".xml";
        NotebookReader reader = new XMLNotebookRepositoryFactory(currentFilename1).createReader();
        notebookEntries = reader.getAll();
        reader.close();
        File temp = new File(currentFilename1);
        temp.delete();

        notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);
        notebookEntryJList.setModel(notebookEntriesListModel);
        notebookEntryJList.repaint();

        if(this.notebookEntries.size() == 0) {
           return;
        }

        notebookEntryJList.setSelectedIndex(0);

        formulaTxt.setText(((NotebookEntry)(notebookEntryJList.getSelectedValue())).functionString);
         ne = (NotebookEntry)(notebookEntryJList.getSelectedValue());

         ne.minXCoordinate = -5.0;
         ne.maxXCoordinate = 5.0;
         ne.minYCoordinate = -5.0;
         ne.maxYCoordinate = 5.0;

       //set graph hash marks
         graphMinX.setText(ne.minXCoordinate + "");
         graphMaxX.setText(ne.maxXCoordinate + "");
         graphMinY.setText(ne.minYCoordinate + "");
         graphMaxY.setText(ne.maxYCoordinate + "");

         //set graph size text boxes
         minXTxt.setText(ne.minXCoordinate + "");
         maxXTxt.setText(ne.maxXCoordinate + "");
         minYTxt.setText(ne.minYCoordinate + "");
         maxYTxt.setText(ne.maxYCoordinate + "");

         areaTxt.setText(roundTwoDecimals(ne.calculateArea()) + "");

         graph1.drawGraph(ne);
         graph1.repaint();

         slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
         slopeTbl.setModel(slopeTable);
         slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
         slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
         slopeTbl.repaint();

	 openfromserver = false;
    }

     /**
     * Shows the save as file dialog and writes the XML to the selected file
     * @author Jared Schlicht
     */
    private void saveFileAs() {
        JFileChooser fileChooser = new JFileChooser();

        int saveResult = fileChooser.showSaveDialog(this);
        if (saveResult != JFileChooser.APPROVE_OPTION) {
            return;
        }

        File file = fileChooser.getSelectedFile();
        this.currentFilename = file.getAbsolutePath();

        this.saveFile();
    }


    /**
     * Saves the current notebook entry to XML. The current filename must have
     * been set previously by the Save As method.
     * 
     * @author Jared Schlicht
     */
    private void saveFile() {
        NotebookWriter writer = new XMLNotebookRepositoryFactory(this.currentFilename).createWriter();
        writer.writeAll(notebookEntriesListModel.notebookEntries);
        writer.close();
    }

    /**
     * Removes expression from expression list
     * 
     * @param selected expression
     * @author Mack Butzen
     */
    private void removeExpBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeExpBtnActionPerformed
        try {
        //Reset graph view
        ne.minXCoordinate = -5.0;
        ne.maxXCoordinate = 5.0;
        ne.minYCoordinate = -5.0;
        ne.maxYCoordinate = 5.0;
        ne.functionString = input;

        //set graph hash marks
        graphMinX.setText(ne.minXCoordinate + "");
        graphMaxX.setText(ne.maxXCoordinate + "");
        graphMinY.setText(ne.minYCoordinate + "");
        graphMaxY.setText(ne.maxYCoordinate + "");

        //set graph size text boxes
        minXTxt.setText(ne.minXCoordinate + "");
        maxXTxt.setText(ne.maxXCoordinate + "");
        minYTxt.setText(ne.minYCoordinate + "");
        maxYTxt.setText(ne.maxYCoordinate + "");

        notebookEntriesListModel = new NotebookEntryListModel(notebookEntries);

        ne = new NotebookEntry();
        graph1.drawGraph(ne);
        areaTxt.setText("");
        formulaTxt.setText("");

        slopeTable = new SlopeTable(ne);
        slopeTbl.setModel(slopeTable);
        slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
        slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
        slopeTbl.repaint();

            int index = notebookEntryJList.getSelectedIndex();
            notebookEntries.remove(index);
            notebookEntryJList.setModel(notebookEntriesListModel);
            notebookEntryJList.repaint();
            graph1.repaint();
        }
        catch(Exception e) {}
    }//GEN-LAST:event_removeExpBtnActionPerformed

    private void removeSlopeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSlopeBtnActionPerformed
        try {

            int index = notebookEntryJList.getSelectedIndex();
            notebookEntries.get(index).tangentPoints.remove(slopeTbl.getSelectedRow());
            slopeTable = new SlopeTable((NotebookEntry)(notebookEntryJList.getSelectedValue()));
            slopeTbl.setModel(slopeTable);
            slopeTbl.getColumnModel().getColumn(0).setHeaderValue("X");
            slopeTbl.getColumnModel().getColumn(1).setHeaderValue("Slope");
            slopeTbl.repaint();
            graph1.repaint();
        }
        catch(Exception e) {}
    }//GEN-LAST:event_removeSlopeBtnActionPerformed

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        File file = new File("docs/UserManual.pdf");
        try {
                        Desktop.getDesktop().open(file);
                } catch (IOException e) {
                }
    }//GEN-LAST:event_aboutMenuItemActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Login;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JLabel areaLbl;
    private javax.swing.JLabel areaTxt;
    private javax.swing.JButton drawBtn;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JLabel formulaLbl;
    private javax.swing.JTextField formulaTxt;
    private cs342.project1.mathNotebook.gui.Graph graph1;
    private javax.swing.JLabel graphMaxX;
    private javax.swing.JLabel graphMaxY;
    private javax.swing.JLabel graphMinX;
    private javax.swing.JLabel graphMinY;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblDimensions;
    private javax.swing.JPanel listPnl;
    private javax.swing.JMenuItem CreateUserOnCloudMenuItem;
    private javax.swing.JMenuItem loginOnCloudMenuItem;
    private javax.swing.JMenu loginServer;
    private javax.swing.JLabel maxXLbl;
    private javax.swing.JTextField maxXTxt;
    private javax.swing.JLabel maxYLbl;
    private javax.swing.JTextField maxYTxt;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JLabel minXLbl;
    private javax.swing.JTextField minXTxt;
    private javax.swing.JLabel minYLbl;
    private javax.swing.JTextField minYTxt;
    private javax.swing.JButton newExpBtn;
    private javax.swing.JMenuItem newMenuItem;
    private javax.swing.JList notebookEntryJList;
    private javax.swing.JMenuItem openCompEncMenuItem;
    private javax.swing.JMenuItem openCompMenuItem;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem openOnCloudMenuItem;
    private javax.swing.JButton removeExpBtn;
    private javax.swing.JButton removeSlopeBtn;
    private javax.swing.JMenuItem saveAsCompEncMenuItem;
    private javax.swing.JMenuItem saveAsCompMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveAsOnCloudMenuItem;
    private javax.swing.JMenuItem filesOnCloudMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    private javax.swing.JButton slopeBtn;
    private javax.swing.JScrollPane slopeSbr;
    private javax.swing.JTable slopeTbl;
    private javax.swing.JLabel tangentLbl;
    private javax.swing.JPanel viewPnl;
    private boolean readwritetosql;
    private String username;
    private String passw;
    private String dbURL = null;
    private Connection conn = null;
    private PublicKey rsa_pub_key;
    private PrivateKey rsa_pri_key;
    private SecretKey desKey;
    private DESKeySpec desKeySpec;
    private int openfid;
    private boolean openfromserver = false;
    private BigInteger bi;
    private JTable table;
    private String lastUser;
    // End of variables declaration//GEN-END:variables
}
